package com.hk.service;

import java.util.ArrayList;

import com.hk.dtos.AdminDto;
import com.hk.dtos.UserDto;
import com.hk.ibatis.SqlDaoSuport;
import com.hk.idtos.IUserDto;


public class LoginManager  extends SqlDaoSuport implements IUserDto{
	public UserDto login(String id){
		UserDto dtos = new UserDto();
		try {
			dtos=(UserDto)this.getSqlMapClient().queryForObject("login",id);
		} catch (Exception e) {
			System.out.println(e);
			
		}
			
		return dtos;

		}
	public boolean register(UserDto dto) {
	 	int answer=1;
	 	
	 	try {
			this.getSqlMapClient().insert("register",dto);
		} catch (Exception e) {
			System.out.println(e);
			answer=-1;
	 	}
		return answer>0?true:false;
	 
	 }	
	public String pointup(String id) {
	 		 	
	 	try {
			this.getSqlMapClient().update("pointup",id);
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		return "y";
	 
	 }	
	public String autup(String id) {
		 	
	 	try {
			this.getSqlMapClient().update("autup",id);
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		return "y";
	 
	 }	
	public void update(AdminDto dto) {
	 	
	 	try {
			this.getSqlMapClient().update("aupdate",dto);
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
	 }
public ArrayList<AdminDto> getmenu() {
	ArrayList<AdminDto> ad = null;
	 	try {
			 ad = (ArrayList<AdminDto>)this.getSqlMapClient().queryForList("getmenu");
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		return ad;
	 }
}
